<?php
require_once './model/db.php';
require_once './model/articles.php';
require_once './model/categories.php';
require_once './model/addarticles.php';
$open = new addcategories();
$obj1 = new categories();
$data1 = $obj1->xemca();

$obj = new articles();
$data = $obj->viewupda();
foreach($data as $value)
?>

<form method="post">
    <table border=1>
    <tr>
        <td>title</td>
        <td ><input type="text" value="<?php echo $value["title"] ?>" name="title"></td>
    </tr>
    <tr>
        <td>Overview</td>
        <td><input type="text" value="<?php echo $value["overview"] ?>" name="overview"></td>
    </tr>
    <tr>
        <td>body</td>
        <td><input type="text" value="<?php echo $value["body"] ?>" name="body"></td>
    </tr>
    <tr>
        <td>category</td>
        <td>
            <select name="categories">
                
         
            <?php foreach($data1 as $value1){ 
                ?>
                
                <option value="<?php  echo $value1["id"]  ?> "  ><?php echo $value1["name"] ?></option>
            <?php }?>
            </select>
        </td>
    </tr>
    <tr>
        <td colspan="2"><input type="submit" name="ok" value="EDIT"></td>
    </tr>
</table>
</form>
<?php
    if(isset($_POST["ok"]))
    {
       
        $data1 = $_POST["title"];
        $data2 = $_POST["overview"];
        $data3 = $_POST["body"];
        $data4 = $_POST["categories"];
        $open->upda($data1, $data2, $data3, $data4 );
        header("location: index_showsanpham.php");
    }
?>
